<template>
	<view style="padding: 20upx 40upx;">
		<view class="item" style="width: 100%;margin: 20upx 0upx;min-height: 386upx;border-radius: 20upx;border: 1upx solid #DDDDDD;box-shadow: 1upx 1upx 10upx #DDDDDD;position: relative;color: #fff;background-image: #444444;background-image: linear-gradient(to right, #222222,#555555,#999999,#333333);background-repeat:no-repeat;background-size: 750upx 386upx;">
			<view style="position: absolute;z-index: 2;left: 0;top: 0;width: 95%;margin: 0 2.5%;">
				<view style="margin: 30upx 50upx;">
					可提现总金额(CNY)
				</view>
				<view style="position: relative;">
					<text style="font-size: 70upx;margin: 20upx 50upx;">{{res.commision}}</text>
					<view @click="towithdraw" style="position: absolute;right: 50upx;top: 0upx;width: 150upx;border: 3upx solid #fff; border-radius: 30upx;color: #fff;text-align: center;">
						提现
					</view>
				</view>
				<view style="position: relative;">
					<text style="font-size: 50upx;margin: 30upx 50upx 0upx 50upx;">{{res.commisionTotal}}</text>
					<view style="margin-left: 60upx;margin-top: -13px;">
						累计收益
					</view>
					<view  @click="toanalysis" style="position: absolute;right: 50upx;top: 0upx;width: 150upx;border: 3upx solid #fff; border-radius: 30upx;color: #fff;text-align: center;">
						收益明细
					</view>
				</view>
			</view>
		</view>
		<!-- <view style="height: 180upx; position: relative;" class="list-cell b-b m-t" @click="jump" data-src="./balance" hover-class="cell-hover" :hover-stay-time="50">
			<text class="cell-tit" style="font-size: 40upx;position: absolute;top: 40upx;left: 40upx;">{{res.levelPrice}}</text>
			<text class="cell-tit" style="position: absolute;top: 80upx;left: 40upx;">首批余额</text>
			<text class="cell-more yticon icon-you" style="position: absolute;top: 60upx;right: 40upx;"></text>
		</view> -->
		<view class="list-cell b-b m-t" @click="jump" data-src="./performance" hover-class="cell-hover" :hover-stay-time="50">
			<text class="cell-tit">我的业绩</text>
			<text class="cell-more yticon icon-you"></text>
		</view>
		<view class="list-cell b-b m-t" @click="jump" data-src="../coupon/coupon" hover-class="cell-hover" :hover-stay-time="50">
			<text class="cell-tit">我的优惠券</text>
			<text class="cell-more yticon icon-you"></text>
		</view>
		<view class="list-cell b-b m-t" @click="jump" data-src="./invoice" hover-class="cell-hover" :hover-stay-time="50">
			<text class="cell-tit">发票信息</text>
			<text class="cell-more yticon icon-you"></text>
		</view>
		<view class="list-cell b-b m-t" @click="jump" data-src="./levelPrice" hover-class="cell-hover" :hover-stay-time="50">
			<text class="cell-tit">我的余额</text> <text style="padding-left: 10upx;color: #FF3333;">{{res.balance}}</text>
			<text class="cell-more yticon icon-you"></text>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				res:[],
				user_id:'',
				
			};
		},
		onLoad:function(){
			uni.showLoading()
			uni.getStorage({
				key: 'timestamp',
				success: (res) => {
					this.timestamp = res.data
				},
			});
			uni.getStorage({
				key: 'token',
				success: (res) => {
					this.token = res.data
				},
			});
			uni.getStorage({
				key: 'user_id',
				success: (res) => {
					this.user_id = res.data
					this.setAjax()
				},
				fail: () => {
					uni.navigateTo({
						url: '../../index/index'
					});
				}
			});
		},
		onPullDownRefresh() {
			let o = this
			setTimeout(function () {
				o.setAjax();
				uni.stopPullDownRefresh();
			}, 1000);
		},
		methods:{
			setAjax(){
				uni.request({
					url: 'https://cx.mingmeijt.com/Api/User/myPurse',
					method: 'POST',
					header:{'Content-Type':'application/x-www-form-urlencoded'},
					data:{
						user_id: this.user_id,
						timestamp: this.timestamp,
						token: this.token,
						session_id: uni.getStorageSync("sessionid")
					},
					success: res => {
						if(res.data.code == 999){
							uni.navigateTo({
								url:'/pages/999/999'
							})
						};
						if(res.data.code == 998){
							uni.navigateTo({
								url:'/pages/login/login'
							})
						}
						this.res = res.data.data
					},
					fail: () => {},
					complete: () => {}
				});
				uni.hideLoading()
			},
			towithdraw(){
				uni.navigateTo({
					url:'/pagesA/user/qianbao/withdraw/withdraw'
				})
			},
			toanalysis(){
				uni.navigateTo({
					url:'/pagesA/user/qianbao/analysis'
				})
			},
			jump(e){
				uni.navigateTo({
					url: e.currentTarget.dataset.src
				});
			},
		}
	}
</script>

<style lang='scss'>
	page{
		background: $page-color-base;
	}
	.list-cell{
		/* border: 1upx solid #DDDDDD; */
		box-shadow: 1upx 1upx 10upx #DDDDDD;
		border-radius: 20upx;
		display:flex;
		align-items:baseline;
		padding: 20upx $page-row-spacing;
		line-height:60upx;
		position:relative;
		background: #fff;
		justify-content: center;
		&.log-out-btn{
			margin-top: 40upx;
			.cell-tit{
				color: #000;
				text-align: center;
				margin-right: 0;
			}
		}
		&.cell-hover{
			background:#fafafa;
		}
		&.b-b:after{
			left: 30upx;
		}
		&.m-t{
			margin-top: 16upx; 
		}
		.cell-more{
			align-self: baseline;
			font-size:$font-lg;
			color:$font-color-light;
			margin-left:10upx;
		}
		.cell-tit{
			flex: 1;
			font-size: $font-base + 2upx;
			color: $font-color-dark;
			margin-right:10upx;
		}
		.cell-tip{
			font-size: $font-base;
			color: $font-color-light;
		}
		switch{
			transform: translateX(16upx) scale(.84);
		}
	}
</style>
